You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@parameter1/mongodb-prop-types

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parameter1/mongodb-prop-types

Common MongoDB prop type validators using Joi.

2.3.0
Source
npmnpm
Version published
Weekly downloads
23
-85.8%
Maintainers
3
Weekly downloads
 
Created
Source

MongoDB Prop Types

Common prop type validators using Joi.

Installation

yarn add @parameter1/mongodb-prop-types

Usage

Prop type schemas.

import { mongoClientProp, mongoCollectionProp, mongoSessionProp } from '@parameter1/mongodb-prop-types';

import { MongoClient } from '@parameter1/mongodb-core';
import Joi from 'joi';

const { attempt } = Joi

const client = new MongoClient('mongodb://some-server:27071');

// valid
attempt(client, mongoClientProp.required());
attempt(client.db('test').collection('foo'), mongoCollectionProp.required());
attempt(client.startSession(), mongoSessionProp.required());

Extending Joi to add objectId type.

import Joi from 'joi';
import { objectIdType } from '@parameter1/mongodb-prop-types';

Joi.extend(objectIdType);

const someObjectId = new ObjectId();

// valid
attempt(someObjectId, Joi.objectId().required());

FAQs

Package last updated on 11 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts